package com.lyl.xxx.modules.web.montior.controller;

import com.github.pagehelper.PageInfo;
import com.lyl.xxx.modules.web.montior.model.dto.OnlineUserDTO;
import com.lyl.xxx.modules.web.montior.model.vo.OnlineUserVO;
import com.lyl.xxx.modules.web.montior.service.OnlineService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotBlank;

@Slf4j
@Validated
@RestController
@RequestMapping("/monitor/online")
@RequiredArgsConstructor
public class OnlineUserController {
    private final OnlineService onlineService;

    @GetMapping("/user/list/{pageNo}/{pageSize}")
    public PageInfo<OnlineUserVO> getOnlineUserList(@PathVariable Integer pageNo,
                                                    @PathVariable Integer pageSize,
                                                    OnlineUserDTO dto){
        return onlineService.getOnlineUserList(pageNo,pageSize,dto);
    }

    @PostMapping("/user/forceLogout")
    public boolean forceLogout(@NotBlank(message = "tokenId不能为空") String tokenId){
        return onlineService.forceLogout(tokenId);
    }
}
